package simpleftp.client.control;
import java.io.File;
import java.util.concurrent.Callable;

import simpleftp.client.control.SimpleFTP;
import simpleftp.client.gui.FTPClientWindow;

public final class Cwder implements Callable<Boolean> {
	
	private SimpleFTP client;
	private String server;
	private String port;
	private FTPClientWindow wind;
	private String user;
	private String pass;
	private File file;

	public Cwder(File f, FTPClientWindow window, String server, String port,
			String user, String pass, SimpleFTP c) {
		this.file = f;
		this.server = server;
		this.port = port;
		this.wind = window;
		this.user = user;
		this.pass = pass;
		client = c;
	}
	
	@Override
	public Boolean call() throws Exception {
		System.out.println("Changing current work directory on the server ");
		Boolean result = false;
		//client.connect(server, Integer.parseInt(port), user, pass);
		
		result = client.cwd(file.getAbsolutePath());
		
		if (result) {
			wind.console.append("Successfully changed CWD"
					+ file.getAbsolutePath());
			System.out.println("Successfully changed CWD"
					+ file.getAbsolutePath());
			
		} else {
			wind.console.append("Failed CWD " + file.getAbsolutePath());
			System.out.println("Failed CWD "
					+ file.getAbsolutePath());
		}
		return result;
	}

}
